using System.Collections.Generic;
using AndyPike.Commons.Persistence;
using AndyPike.Commons.Persistence.InMemory;
using AndyPike.Snowflake.Core.Queries.Accounts;
using AndyPike.Snowflake.Entities;
using NUnit.Framework;
using NUnit.Framework.SyntaxHelpers;

namespace AndyPike.Snowflake.Core.Tests.Unit.Queries.Accounts
{
    [TestFixture]
    public class When_querying_for_accounts_by_user_name
    {
        [Test]
        public void Should_return_matches_from_a_repository()
        {
            var accounts = new List<Account>
                               {
                                   new Account {UserName = "andypike"},
                                   new Account {UserName = "blah"},
                                   new Account {UserName = "andypike"},
                                   new Account {UserName = "another"},
                                   new Account {UserName = "onemore"}
                               };

            IRepository<Account> repository = new InMemoryRepository<Account>(accounts);
            ICollection<Account> matches = repository.Find(new AccountByUserName("andypike"));

            Assert.That(matches.Count, Is.EqualTo(2));
        }
    }
}